package admin

import (
	"fmt"
	"mime"
	"os"

	. "xwaf_admin/xadmin/src/lib"
	"xwaf_admin/xadmin/src/models"

	beego "github.com/beego/beego/v2/server/web"
)

const VERSION = "3.0"

func Run() {
	//初始化
	initialize()

	fmt.Println("Starting....")

	fmt.Println("Start ok")
}
func initialize() {
	mime.AddExtensionType(".css", "text/css")
	//判断初始化参数
	initArgs()
	models.Connect()
	router()
	beego.AddFuncMap("stringsToJson", StringsToJson)
}
func initArgs() {
	args := os.Args
	for _, v := range args {
		if v == "-v" || v == "-version" {
			fmt.Println("xkube" + "-" + VERSION)
			os.Exit(0)
		}
		if v == "-syncdb" {
			models.SyncdbInfo()
			os.Exit(0)
		}
	}
}
